package leecode

func checkAlmostEquivalent(word1 string, word2 string) bool {
	hash1 := make(map[byte]int)
	hash2 := make(map[byte]int)
	for i := 0; i < len(word1); i++ {
		hash1[word1[i]]++
	}
	for i := 0; i < len(word2); i++ {
		hash2[word2[i]]++
	}
	for key, value := range hash1 {
		if hash2[key]-value > 3 || hash2[key]-value < -3 {
			return false
		}
	}
	for key, value := range hash2 {
		if hash1[key]-value > 3 || hash1[key]-value < -3 {
			return false
		}
	}
	return true
}
